package com.qing.design.patterns.decorator.example;

import com.qing.design.patterns.decorator.example.decorators.*;

public class Demo {
    public static void main(String[] args) {
        String salaryRecords="姓名，薪水\\nJohn Smith，100000份工作，912000";
        DataSourceDecorator encoded=new CompressionDecorator(new EncryptionDecorator(new FileDataSource("OutputDemo.txt")));
        encoded.writeData(salaryRecords);
        DataSource plain=new FileDataSource("OutputDemo.txt");

        System.out.println("----input--------------");
        System.out.println(salaryRecords);
        System.out.println("----Encoded-------------");
        System.out.println(plain.readData());
        System.out.println("----Decoded-------------");

        System.out.println(encoded.readData());
    }
}
